import { getListAllDevice, getListAllSensors } from '@/api/device';

const state = {};

const mutations = {

  SET_ALL_DEVICE: (state, Device_list) => {
    state.Device_list = Device_list;
  },
  SET_ALL_SENSOR: (state, Sensor_list) => {
    state.Sensor_list = Sensor_list;
  }
};

const actions = {

  async setDeviceValue({ commit, state }, data) {
    const params = {
      Token: data.token,
      Device_ID: data.Device_ID
    };

  },
  async setAllDevice({ commit, stat }, data) {
    const params = {
      Token: data.token
    };
    const res = await getListAllDevice(params);
    commit('SET_ALL_DEVICE', res.data);
  },
  async setAllSensor({ commit, stat }, data) {
    const params = {
      'Token': data.token,
      'Device_ID': data.Device_ID
    };
    const res = await getListAllSensors(params);
    // console.log("res",res)
    commit('SET_ALL_SENSOR', res);
  }
};

export default {
  namespaced: true,
  state,
  mutations,
  actions
};

